package com.yanggeng.demo.beginnerguidedemo.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yanggeng.demo.beginnerguidedemo.activity.DrawerLayoutActivity;
import com.yanggeng.demo.beginnerguidedemo.R;
import com.yanggeng.demo.beginnerguidedemo.utils.SnackbarUtil;

/**
 * Created by yanggeng on 2017/7/6.
 */

public class HomeFragment extends Fragment {

    Toolbar toolbar;
    View main_view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, null);
        toolbar = (Toolbar) view.findViewById(R.id.home_toolbar);
        main_view = view.findViewById(R.id.home_main_view);
        final DrawerLayout drawerLayout = ((DrawerLayoutActivity) getActivity()).getDrawerLayout();
        view.findViewById(R.id.ib_setting).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SnackbarUtil.longSnackbar(main_view, "点击了设置");
            }
        });
        toolbar.setNavigationIcon(R.mipmap.c_navbar_menu);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                drawerLayout.openDrawer(GravityCompat.START);
            }
        });

        return view;
    }
}
